package concurrency;

import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;

public class RxJavaTest {
    public static void main(String[] args) throws InterruptedException {
        Disposable complete = Observable.just(5, 10, 15).observeOn(Schedulers.computation()).doOnNext(e -> {
            Thread.sleep(1000);
            System.out.println(Thread.currentThread().getName() + ": " + e);
        }).doOnNext(e -> {
            Thread.sleep(2000);
            System.out.println(Thread.currentThread().getName() + ": " + e);
        }).doOnComplete(() -> {
            System.out.println(Thread.currentThread().getName() + ": complete");
        }).subscribe(e -> {
            System.out.println(Thread.currentThread().getName() + ": subscribe do on next, " + e);
        });

        Thread.sleep(10000L);
    }
}
